home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_mac.hqx / SRGP port to 5.0 (compressed) / SRGP_SPHIGS Root / MacSRGP / srgp_raster.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-13  |  2.7 KB  |  88 lines

  1. #include "HEADERS.h"
  2. #include "srgplocal.h"
  3.  
  4. #ifdef THINK_C
  5. #include "ChooseWhichQuickdraw.h"
  6. #endif
  7.  
  8. #define DFIXED(yy)\
  9. (srgp__curActiveCanvasSpec.max_ycoord - (yy))
  10. #define SFIXED(yy)\
  11. (srgp__canvasTable[source_canvas_id].max_ycoord - (yy))
  12.  
  13. #include "srgp_raster.proto.h"
  14.  
  15.  
  16. void
  17. SRGP_copyPixel (canvasID source_canvas_id, 
  18.         rectangle source_rect, 
  19.         point dest_corner)
  20. {
  21.    register int height;
  22.  
  23.    DEBUG_AIDS{
  24.       SRGP_trace (SRGP_logStream, "SRGP_copyPixel: %d (%d,%d)->(%d,%d) -----> (%d,%d)\n",
  25.           source_canvas_id, ExplodeRect(source_rect), ExplodePt(dest_corner));
  26.       srgp_check_system_state();
  27.       srgp_check_extant_canvas (source_canvas_id);
  28.       srgp_check_rectangle
  29.      (source_rect.bottom_left.x, source_rect.bottom_left.y,
  30.       source_rect.top_right.x, source_rect.top_right.y);
  31.       LeaveIfNonFatalErr();
  32.    }
  33.  
  34.  
  35. #ifdef X11
  36.    height = (source_rect.top_right.y - source_rect.bottom_left.y + 1);
  37.    XCopyArea (srgpx__display,
  38.           srgp__canvasTable[source_canvas_id].drawable.bitmap,
  39.           srgp__curActiveCanvasSpec.drawable.bitmap,
  40.           srgp__curActiveCanvasSpec.gc_fill,
  41.           source_rect.bottom_left.x, SFIXED(source_rect.top_right.y),
  42.           (source_rect.top_right.x - source_rect.bottom_left.x + 1),
  43.           height,
  44.           dest_corner.x, DFIXED(dest_corner.y + height - 1));
  45. #endif
  46.  
  47. #ifdef THINK_C
  48. {
  49.    Rect sRect, dRect;
  50.    int modeTable[] = {srcCopy, srcXor, srcOr, notSrcBic};
  51. #ifdef COLOR_QUICKDRAW
  52.    CGrafPtr curcgport = (CGrafPtr)thePort;
  53.    long savefgcolor, savebgcolor;
  54. #endif
  55.    
  56.    
  57.    SetRect (&sRect, source_rect.bottom_left.x, SFIXED(source_rect.top_right.y), 
  58.        source_rect.top_right.x+1, SFIXED(source_rect.bottom_left.y) + 1);
  59.    SetRect(&dRect, 
  60.        dest_corner.x, 
  61.        DFIXED(dest_corner.y + source_rect.top_right.y - source_rect.bottom_left.y),
  62.        dest_corner.x + source_rect.top_right.x - source_rect.bottom_left.x + 1, 
  63.        DFIXED(dest_corner.y) + 1);
  64.  
  65. #ifdef COLOR_QUICKDRAW       
  66.    savefgcolor = thePort->fgColor; savebgcolor = thePort->bkColor;
  67.    thePort->fgColor = 255;  thePort->bkColor = 0;  /*THIS IS DANGEROUSLY STUPID*/
  68.    
  69. #  define canvasGrafport(i) (*((CGrafPtr)(srgp__canvasTable[i].drawable.xid)))
  70.    CopyBits (*(canvasGrafport(source_canvas_id).portPixMap), 
  71.          *(canvasGrafport(srgp__curActiveCanvasId).portPixMap), 
  72.              &sRect, &dRect, 
  73.              modeTable[srgp__curActiveCanvasSpec.attributes.write_mode], NULL);
  74.  
  75.    thePort->fgColor = savefgcolor;  thePort->bkColor = savebgcolor;
  76. #else
  77. #  define canvasGrafport(i) (*((GrafPtr)(srgp__canvasTable[i].drawable.xid)))
  78.    CopyBits (&(canvasGrafport(source_canvas_id).portBits), 
  79.          &(canvasGrafport(srgp__curActiveCanvasId).portBits), 
  80.              &sRect, &dRect, 
  81.              modeTable[srgp__curActiveCanvasSpec.attributes.write_mode], NULL);
  82.  
  83. #endif
  84. }
  85. #endif
  86.  
  87. }
  88.